<#-- 登录页面 -->
<#include "/WEB-INF/default/fragment/nev.ftl">
<div class="container">
          <form class="form j-user-login" action="${request.contextPath}/login-post.action" method="post">
            <fieldset>
              <legend class="clearfix">
                <span class="pull-left">一技在手，天下我有</span>
                <span class="pull-right">请登录</span>
              </legend>
              <div class="form-group">
                <label for="exampleInputEmail1">邮箱</label>
                <input type="text" class="form-control" id="exampleInputEmail1" name="email" placeholder="Email">
                <p class="help-block"></p>
              </div>
              <div class="form-group">
                <label for="exampleInputPassword1">密码</label>
                <input type="password" class="form-control" id="exampleInputPassword1" name="passwd" placeholder="Password">
                <p class="help-block"></p>
              </div>
              <div class="checkbox">
                <label><input type="checkbox" name="remeberMe" value="1" checked> 记住我</label>
              </div>
              <button type="submit" class="btn btn-success btn-block j_submit_button" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> 正在验证">登录</button>
            </fieldset>
          </form>
      </div>
  <script>
    $(document).on('submit', '.j-user-login', function() {
       var param = $('.j-user-login').serialize();
       param = param + '&struts.enableJSONValidation=true';
       $('.j_submit_button').button('loading');
       $.post('${request.contextPath}/login-post.action', param, function(data, textStatus, xhr) {
         $('.j_submit_button').button('reset');
        if(data['fieldErrors'] != null) {
            for (var i in data['fieldErrors']) {
            $('input[name="'+i+'"]').next().html(data['fieldErrors'][i]);
            }
            return;
        }
        if (data['status'] === 1) { // 恒等于，数据类型和值都相等
      window.location.href = '${request.contextPath}/index.action';
    }
    if (data['status'] === 0) { // 恒等于，数据类型和值都相等
      alert(data['message']);
    }
    console.log(data);
       });
    });
</script>
<#include "/WEB-INF/default/fragment/footer.ftl">